package com.maila.simplerecord.activity;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.maila.simplerecord.R;
import com.maila.simplerecord.adapter.AllProjectAdapter;
import com.maila.simplerecord.data.Projectdata;
import com.zhy.autolayout.AutoLayoutActivity;
import com.zhy.autolayout.AutoRelativeLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 全部项目列表
 * Created by Administrator on 2017/6/2.
 */
public class AllProjectListActivity extends AutoLayoutActivity {
    @BindView(R.id.white_return_iv)
    ImageView whiteReturnIv;
    @BindView(R.id.white_message_iv)
    TextView whiteMessageIv;
    @BindView(R.id.arl_art)
    AutoRelativeLayout arlArt;
    @BindView(R.id.lv_allproject)
    ListView lvAllproject;
    AllProjectAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_allprojectlist);
        ButterKnife.bind(this);
        adapter=new AllProjectAdapter(this);
        lvAllproject.setAdapter(adapter);
        initdata();
    }

    private void initdata() {
        new AsyncTask<Void, Void, List<Projectdata>>() {
            @Override
            protected List<Projectdata> doInBackground(Void... params) {
               List<Projectdata> mdata = new ArrayList<>();
                mdata= Projectdata.getAlled(0);
                return mdata;
            }
            @Override
            protected void onPostExecute(List<Projectdata> mdata) {
                super.onPostExecute(mdata);
                adapter.setMdata(mdata);
            }
        }.execute();
    }

    @OnClick(R.id.white_return_iv)
    public void onViewClicked() {
        finish();
    }
}
